package tests;

import common.Utils;
import org.openqa.selenium.By;

public class LoginPage extends Utils {
    public static String url = "http://49.235.61.184:8080/user/login";
    public LoginPage() {
        super(url);
    }

    //检查登录页面
    public void checkLoginPage() {
        //检查头像是否可见
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.top___1C1Zi > div.header___5xZ3f > img"));
     //检查主标题是否可见
       String title =  driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.top___1C1Zi > div.header___5xZ3f > span")).getText();
      //校验
        assert title.equals("问卷调查系统");
       //检查小标题是否可见
        String Subtitle = driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.top___1C1Zi > div.desc___-njyT")).getText();
    //校验
        assert Subtitle.equals("做更好的调查问卷系统");
        //检查用户输入框的小头像是否可见
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > div:nth-child(2) > div > div > div > div > span > span.ant-input-prefix > span > svg > path"));
        //检查密码输入框的小头像是否可见
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > div:nth-child(3) > div > div > div > div > span > span.ant-input-prefix > span > svg > path"));
        //检查用户登录框是否可见
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > div:nth-child(2) > div > div > div > div > span"));
        //检查密码输入框是否可见
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > div:nth-child(3) > div > div > div > div > span"));
        //检查输入密码框不可见小头像是否可见
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > div:nth-child(3) > div > div > div > div > span > span.ant-input-suffix > span > svg"));
        //检查注册账户按钮是否可见字符是否正确
        String register = driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > div:nth-child(4) > a")).getText();
        //校验
        assert register.equals("注册账户");
        //检查登录按钮是否可见
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > button"));
        //检查登录字段是否正确
        String Login_button  =  driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > button > span")).getText();
        //校验
        assert Login_button.equals("登录");
        //检查切换语言的按钮是否可见
        driver.findElement(By.cssSelector("#root > div > div.lang___l6cji > span > i > svg"));
    }
}
